<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>GSoC2011SfM: D:/Travail/These/Determination caracteristiques camera/GSoC/SfM/src/SequenceAnalyzer.cpp Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  <td id="projectlogo"><img alt="Logo" src="logo.png"/></td>
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">GSoC2011SfM
   &#160;<span id="projectnumber">0.1</span>
   </div>
   <div id="projectbrief">Google Summer of Code 2011: Structure from motion</div>
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">D:/Travail/These/Determination caracteristiques camera/GSoC/SfM/src/SequenceAnalyzer.cpp</div>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00002"></a>00002 <span class="preprocessor">#include &lt;boost/thread/thread.hpp&gt;</span>
<a name="l00003"></a>00003 
<a name="l00004"></a>00004 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00005"></a>00005 <span class="preprocessor">#include &lt;sstream&gt;</span>
<a name="l00006"></a>00006 
<a name="l00007"></a>00007 <span class="preprocessor">#include &quot;SequenceAnalyzer.h&quot;</span>
<a name="l00008"></a>00008 <span class="preprocessor">#include &quot;Boost_Matching.h&quot;</span>
<a name="l00009"></a>00009 <span class="preprocessor">#include &quot;Camera.h&quot;</span>
<a name="l00010"></a>00010 
<a name="l00011"></a>00011 <span class="preprocessor">#include &quot;config_SFM.h&quot;</span>  <span class="comment">//SEMAPHORE</span>
<a name="l00012"></a>00012 
<a name="l00013"></a>00013 <span class="keyword">using</span> cv::Ptr;
<a name="l00014"></a>00014 <span class="keyword">using</span> cv::Mat;
<a name="l00015"></a>00015 <span class="keyword">using</span> cv::DMatch;
<a name="l00016"></a>00016 <span class="keyword">using</span> cv::KeyPoint;
<a name="l00017"></a>00017 <span class="keyword">using</span> std::vector;
<a name="l00018"></a>00018 <span class="keyword">using</span> cv::Point3d;
<a name="l00019"></a>00019 
<a name="l00020"></a>00020 <span class="keyword">namespace </span>OpencvSfM{
<a name="l00021"></a>00021 
<a name="l00022"></a>00022   <span class="keywordtype">int</span> <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a3038a412036acf7743cb6f2306a5d349" title="Minimum points detected into an image to keep this estimation (set to 20)">SequenceAnalyzer::mininum_points_matches</a> = 20;
<a name="l00023"></a>00023   <span class="keywordtype">int</span> <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a2b2137918a91c3931b9688402783ea4e" title="Minimum images connections in a track to keep this estimation (usually set to 2)">SequenceAnalyzer::mininum_image_matches</a> = 2;
<a name="l00024"></a>00024 
<a name="l00025"></a><a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ab77d7d385adf8fbfe82695a0a9ed2179">00025</a>   <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ab77d7d385adf8fbfe82695a0a9ed2179">SequenceAnalyzer::SequenceAnalyzer</a>( <a class="code" href="class_opencv_sf_m_1_1_motion_processor.html" title="This class try to create a commun interface for files loading. Indeed, if you want to use webcam...">MotionProcessor</a> input_sequence,
<a name="l00026"></a>00026     cv::Ptr&lt; cv::FeatureDetector &gt; feature_detector,
<a name="l00027"></a>00027     cv::Ptr&lt; cv::DescriptorExtractor &gt; descriptor_extractor,
<a name="l00028"></a>00028     cv::Ptr&lt; PointsMatcher &gt; match_algorithm )
<a name="l00029"></a>00029     :match_algorithm_( match_algorithm ),
<a name="l00030"></a>00030     feature_detector_( feature_detector ),
<a name="l00031"></a>00031     descriptor_extractor_( descriptor_extractor )
<a name="l00032"></a>00032   {
<a name="l00033"></a>00033     <span class="comment">//only finite sequences can be used:</span>
<a name="l00034"></a>00034     CV_DbgAssert( input_sequence.<a class="code" href="class_opencv_sf_m_1_1_motion_processor.html#a30629fa0a0f3f9a941a97a27c618e22a">isBidirectional</a>( ) );
<a name="l00035"></a>00035     <span class="comment">//go back to the begining:</span>
<a name="l00036"></a>00036     input_sequence.<a class="code" href="class_opencv_sf_m_1_1_motion_processor.html#a32865291f286da0855b6aee7f726fa77">setProperty</a>( CV_CAP_PROP_POS_FRAMES,0 );
<a name="l00037"></a>00037 
<a name="l00038"></a>00038     <span class="comment">//load entire sequence! Can be problematic but if a user want to have</span>
<a name="l00039"></a>00039     <span class="comment">//more controls, he can use the other constructor...</span>
<a name="l00040"></a>00040 
<a name="l00041"></a>00041     <span class="keywordtype">int</span> nbFrame=0;
<a name="l00042"></a>00042     Mat currentImage=input_sequence.<a class="code" href="class_opencv_sf_m_1_1_motion_processor.html#abc9166f0cc101aa7eeae14643f7e2674">getFrame</a>( );
<a name="l00043"></a>00043     <span class="keywordflow">while</span> ( !currentImage.empty( ) )<span class="comment">// &amp;&amp; nbFrame&lt;50 )</span>
<a name="l00044"></a>00044     {
<a name="l00045"></a>00045 
<a name="l00046"></a>00046       Ptr&lt;PointsToTrack&gt; ptrPoints_tmp( <span class="keyword">new</span> <a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html" title="This class can be used to find points and features in pictures using SIFT detector.">PointsToTrackWithImage</a> (
<a name="l00047"></a>00047         nbFrame, currentImage, Mat( ), feature_detector, descriptor_extractor ));
<a name="l00048"></a>00048 
<a name="l00049"></a>00049       <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a9e7d1e57d4ff2a80d5ce405e203020b9">points_to_track_</a>.push_back( ptrPoints_tmp );
<a name="l00050"></a>00050       <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a07a0b188400adf992b78ada7db54de0e">images_</a>.push_back( currentImage );
<a name="l00051"></a>00051       nbFrame++;
<a name="l00052"></a>00052       currentImage=input_sequence.<a class="code" href="class_opencv_sf_m_1_1_motion_processor.html#abc9166f0cc101aa7eeae14643f7e2674">getFrame</a>( );
<a name="l00053"></a>00053     }
<a name="l00054"></a>00054   }
<a name="l00055"></a>00055 
<a name="l00056"></a><a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ac26dbd5b551cbabcd76f58aca4a5b451">00056</a>   <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ab77d7d385adf8fbfe82695a0a9ed2179">SequenceAnalyzer::SequenceAnalyzer</a>(
<a name="l00057"></a>00057     std::vector&lt; cv::Ptr&lt; PointsToTrack &gt; &gt; &amp;points_to_track,
<a name="l00058"></a>00058     cv::Ptr&lt;PointsMatcher&gt; match_algorithm,
<a name="l00059"></a>00059     <span class="keyword">const</span> std::vector&lt; cv::Mat &gt; &amp;images )
<a name="l00060"></a>00060     :images_( images ),points_to_track_( points_to_track ),
<a name="l00061"></a>00061     match_algorithm_( match_algorithm )
<a name="l00062"></a>00062   {
<a name="l00063"></a>00063   }
<a name="l00064"></a>00064 
<a name="l00065"></a>00065   <span class="keyword">using</span> cv::DescriptorMatcher;
<a name="l00066"></a>00066   <span class="keyword">using</span> cv::FlannBasedMatcher;
<a name="l00067"></a>00067   <span class="comment">//by default, use flann based matcher</span>
<a name="l00068"></a><a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#aa9b1972ae0c6e2037b70b5d1aadb4ebf">00068</a>   <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ab77d7d385adf8fbfe82695a0a9ed2179">SequenceAnalyzer::SequenceAnalyzer</a>( cv::FileNode file, std::vector&lt;cv::Mat&gt; &amp;images )
<a name="l00069"></a>00069     :images_( images ),
<a name="l00070"></a>00070     match_algorithm_( new <a class="code" href="class_opencv_sf_m_1_1_points_matcher.html" title="A class used for matching descriptors that can be described as vectors in a finite-dimensional space...">PointsMatcher</a>( Ptr&lt;DescriptorMatcher&gt;( new FlannBasedMatcher( ) )) )
<a name="l00071"></a>00071   {
<a name="l00072"></a>00072     <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a3ffb8dd9711b61523c7f58ffc4ec5bee">read</a>( file,*<span class="keyword">this</span> );
<a name="l00073"></a>00073   }
<a name="l00074"></a>00074 
<a name="l00075"></a><a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#aeb174b565dd04f2a68a915ec3a3a99e3">00075</a>   <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#aeb174b565dd04f2a68a915ec3a3a99e3">SequenceAnalyzer::~SequenceAnalyzer</a>( <span class="keywordtype">void</span> )
<a name="l00076"></a>00076   {
<a name="l00077"></a>00077   }
<a name="l00078"></a>00078 
<a name="l00079"></a><a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ad410898bc12c45b6d4dc3f1b807146c2">00079</a>   <span class="keywordtype">void</span> <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ad410898bc12c45b6d4dc3f1b807146c2">SequenceAnalyzer::addNewImage</a>( cv::Mat image, cv::Ptr&lt;PointsToTrack&gt; points )
<a name="l00080"></a>00080   {
<a name="l00081"></a>00081     <span class="keywordflow">if</span>( points.empty( ) )
<a name="l00082"></a>00082     {
<a name="l00083"></a>00083       CV_DbgAssert( !<a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a38f83c0401b027598dce9117a6fb7a54">feature_detector_</a>.empty( ) &amp;&amp;
<a name="l00084"></a>00084         !<a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a4c10b16ab49da0a79c0f2804ff9ae655">descriptor_extractor_</a>.empty( ) );
<a name="l00085"></a>00085       <span class="keywordtype">int</span> nbFrame = <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a9e7d1e57d4ff2a80d5ce405e203020b9">points_to_track_</a>.size( );
<a name="l00086"></a>00086       Ptr&lt;PointsToTrack&gt; ptrPoints_tmp( <span class="keyword">new</span> <a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html" title="This class can be used to find points and features in pictures using SIFT detector.">PointsToTrackWithImage</a> (
<a name="l00087"></a>00087         nbFrame, image, Mat( ), <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a38f83c0401b027598dce9117a6fb7a54">feature_detector_</a>, <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a4c10b16ab49da0a79c0f2804ff9ae655">descriptor_extractor_</a> ));
<a name="l00088"></a>00088       ptrPoints_tmp-&gt;computeKeypointsAndDesc( );
<a name="l00089"></a>00089 
<a name="l00090"></a>00090       <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a9e7d1e57d4ff2a80d5ce405e203020b9">points_to_track_</a>.push_back( ptrPoints_tmp );
<a name="l00091"></a>00091     }
<a name="l00092"></a>00092     <span class="keywordflow">else</span>
<a name="l00093"></a>00093       <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a9e7d1e57d4ff2a80d5ce405e203020b9">points_to_track_</a>.push_back( points );
<a name="l00094"></a>00094 
<a name="l00095"></a>00095     <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a07a0b188400adf992b78ada7db54de0e">images_</a>.push_back( image );
<a name="l00096"></a>00096   }
<a name="l00097"></a>00097   
<a name="l00098"></a><a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a3d58130e9e4fc7e297991709c656c43d">00098</a>   <span class="keywordtype">void</span> <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a3d58130e9e4fc7e297991709c656c43d">SequenceAnalyzer::computeMatches</a>( )
<a name="l00099"></a>00099   {
<a name="l00100"></a>00100     <span class="comment">//First compute missing features descriptors:</span>
<a name="l00101"></a>00101     vector&lt; Ptr&lt; PointsToTrack &gt; &gt;::iterator it =
<a name="l00102"></a>00102       <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a9e7d1e57d4ff2a80d5ce405e203020b9">points_to_track_</a>.begin( );
<a name="l00103"></a>00103     <a class="code" href="struct_opencv_sf_m_1_1_matching_thread.html#af4032a6ff57159ff1854bcb3039c2509" title="End of list images of points. It&#39;s the same for every thread, so set once for every thread before run...">MatchingThread::end_matches_it</a> = <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a9e7d1e57d4ff2a80d5ce405e203020b9">points_to_track_</a>.end( );
<a name="l00104"></a>00104     <a class="code" href="struct_opencv_sf_m_1_1_matching_thread.html#a560bf2489beba3822c9549f3514c6966" title="The algorithm to use for matching.">MatchingThread::match_algorithm</a> = <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a3c3ffb9390f94294e010d38e64bffc25">match_algorithm_</a>;
<a name="l00105"></a>00105 
<a name="l00106"></a>00106     <span class="comment">//Try to match each picture with other:</span>
<a name="l00107"></a>00107     vector&lt;Mat&gt; masks;
<a name="l00108"></a>00108     vector&lt; Ptr&lt; PointsToTrack &gt; &gt;::iterator matches_it = <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a9e7d1e57d4ff2a80d5ce405e203020b9">points_to_track_</a>.begin( );
<a name="l00109"></a>00109 
<a name="l00110"></a>00110     <a class="code" href="struct_opencv_sf_m_1_1_matching_thread.html#ada0799eb3adfb43cc720d75b85a35b98" title="Minimum matches between two images to accept the matches.">MatchingThread::mininum_points_matches</a> = <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a3038a412036acf7743cb6f2306a5d349" title="Minimum points detected into an image to keep this estimation (set to 20)">mininum_points_matches</a>;
<a name="l00111"></a>00111     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nb_proc = boost::thread::hardware_concurrency();
<a name="l00112"></a>00112     INIT_SEMAPHORE( MatchingThread::thread_concurr,nb_proc );
<a name="l00113"></a>00113     INIT_MUTEX( MatchingThread::thread_unicity );
<a name="l00114"></a>00114 
<a name="l00115"></a>00115     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0;
<a name="l00116"></a>00116 
<a name="l00117"></a>00117     <span class="keywordflow">while</span> ( matches_it != <a class="code" href="struct_opencv_sf_m_1_1_matching_thread.html#af4032a6ff57159ff1854bcb3039c2509" title="End of list images of points. It&#39;s the same for every thread, so set once for every thread before run...">MatchingThread::end_matches_it</a> )
<a name="l00118"></a>00118     {
<a name="l00119"></a>00119       <span class="comment">//can we start a new thread?</span>
<a name="l00120"></a>00120       P_MUTEX( MatchingThread::thread_concurr );
<a name="l00121"></a>00121       <span class="comment">//create local values for the thead:</span>
<a name="l00122"></a>00122       <a class="code" href="struct_opencv_sf_m_1_1_matching_thread.html" title="This struct is used by boost::thread object to compute match. I used some semaphore to ensure the mat...">MatchingThread</a> match_thread(<span class="keyword">this</span>, i, matches_it);
<a name="l00123"></a>00123       <span class="comment">//start the thread:</span>
<a name="l00124"></a>00124       boost::thread myThread(match_thread);
<a name="l00125"></a>00125 
<a name="l00126"></a>00126       i++;
<a name="l00127"></a>00127       matches_it++;
<a name="l00128"></a>00128     }
<a name="l00129"></a>00129     <span class="keywordflow">for</span>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> wait_endThread = 0;
<a name="l00130"></a>00130       wait_endThread&lt;nb_proc ; ++wait_endThread)
<a name="l00131"></a>00131       P_MUTEX( MatchingThread::thread_concurr );<span class="comment">//wait for last threads</span>
<a name="l00132"></a>00132 
<a name="l00133"></a>00133     <span class="comment">//compute the color of each matches:</span>
<a name="l00134"></a>00134     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> max_tracks = <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ab259863b967c142950a96bc472fd65ef">tracks_</a>.size();
<a name="l00135"></a>00135     <span class="keywordflow">for</span>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> t=0;t&lt;max_tracks; t++)
<a name="l00136"></a>00136     {
<a name="l00137"></a>00137       <a class="code" href="class_opencv_sf_m_1_1_track_of_points.html" title="This class store the track of keypoints. A track is a connected set of matching keypoints across mult...">TrackOfPoints</a>&amp; tmp = <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ab259863b967c142950a96bc472fd65ef">tracks_</a>[t];
<a name="l00138"></a>00138       <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> max_points = tmp.<a class="code" href="class_opencv_sf_m_1_1_track_of_points.html#a245986f9cdf722e5aec386585677a188" title="List of point indexes of unordered points.">point_indexes_</a>.size();
<a name="l00139"></a>00139       <span class="keywordtype">int</span> R = 0, G = 0, B = 0;
<a name="l00140"></a>00140       <span class="keywordflow">for</span>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> j=0; j&lt;max_points; ++j)
<a name="l00141"></a>00141       {
<a name="l00142"></a>00142         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> img_idx = tmp.<a class="code" href="class_opencv_sf_m_1_1_track_of_points.html#a3a03a4468cd94b38de2b8a9787379801" title="List of image indexes of unordered points.">images_indexes_</a>[j];
<a name="l00143"></a>00143         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> pt_idx = tmp.<a class="code" href="class_opencv_sf_m_1_1_track_of_points.html#a245986f9cdf722e5aec386585677a188" title="List of point indexes of unordered points.">point_indexes_</a>[j];
<a name="l00144"></a>00144 
<a name="l00145"></a>00145         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> packed_color = <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a9e7d1e57d4ff2a80d5ce405e203020b9">points_to_track_</a>[ img_idx ]-&gt;getColor( pt_idx );
<a name="l00146"></a>00146         R += (packed_color&gt;&gt;16) &amp; 0x000000FF;
<a name="l00147"></a>00147         G += (packed_color&gt;&gt;8) &amp; 0x000000FF;
<a name="l00148"></a>00148         B += (packed_color) &amp; 0x000000FF;
<a name="l00149"></a>00149       }
<a name="l00150"></a>00150       R /= max_points;
<a name="l00151"></a>00151       G /= max_points;
<a name="l00152"></a>00152       B /= max_points;
<a name="l00153"></a>00153       tmp.<a class="code" href="class_opencv_sf_m_1_1_track_of_points.html#a2466ba86153215a339806c9a86322195" title="Color of this point (computed using the mean of every 2D points projections.">color</a> = (<span class="keywordtype">unsigned</span> int)(
<a name="l00154"></a>00154         ((R&lt;&lt;16) &amp; 0x00FF0000) | ((R&lt;&lt;8) &amp; 0x0000FF00)| (B &amp; 0x000000FF));
<a name="l00155"></a>00155     }
<a name="l00156"></a>00156   }
<a name="l00157"></a>00157 
<a name="l00158"></a><a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a694fee23e02afc94b48fcfea7ecf2512">00158</a>   <span class="keywordtype">void</span> <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a694fee23e02afc94b48fcfea7ecf2512">SequenceAnalyzer::keepOnlyCorrectMatches</a>(
<a name="l00159"></a>00159     std::vector&lt;TrackOfPoints&gt;&amp; tracks,
<a name="l00160"></a>00160     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> min_matches, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> min_consistance )
<a name="l00161"></a>00161   {
<a name="l00162"></a>00162     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> tracks_size = tracks.size( );
<a name="l00163"></a>00163     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> index=0;
<a name="l00164"></a>00164 
<a name="l00165"></a>00165     <span class="keywordflow">while</span> ( index &lt; tracks_size )
<a name="l00166"></a>00166     {
<a name="l00167"></a>00167       <span class="keywordflow">if</span>( ( tracks[ index ].getNbTrack( ) &lt; min_matches ) ||
<a name="l00168"></a>00168         ( tracks[ index ].track_consistance &lt; (<span class="keywordtype">int</span>)min_consistance ) )
<a name="l00169"></a>00169       {
<a name="l00170"></a>00170         <span class="comment">//problem with this track, too small to be consistent</span>
<a name="l00171"></a>00171         <span class="comment">// or inconsistant...</span>
<a name="l00172"></a>00172         tracks_size--;
<a name="l00173"></a>00173         tracks[ index ]=tracks[ tracks_size ];
<a name="l00174"></a>00174         tracks.pop_back( );
<a name="l00175"></a>00175         index--;
<a name="l00176"></a>00176       }
<a name="l00177"></a>00177       index++;
<a name="l00178"></a>00178     }
<a name="l00179"></a>00179   }
<a name="l00180"></a>00180 
<a name="l00181"></a><a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ad991a56c277be011aa5a85d2478553d5">00181</a>   <span class="keywordtype">void</span> <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ad991a56c277be011aa5a85d2478553d5">SequenceAnalyzer::addMatches</a>( std::vector&lt; cv::DMatch &gt; &amp;newMatches,
<a name="l00182"></a>00182     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> img1, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> img2 )
<a name="l00183"></a>00183   {
<a name="l00184"></a>00184     <span class="comment">//add to tracks_ the new matches:</span>
<a name="l00185"></a>00185 
<a name="l00186"></a>00186     vector&lt;DMatch&gt;::iterator match_it = newMatches.begin( );
<a name="l00187"></a>00187     vector&lt;DMatch&gt;::iterator match_it_end = newMatches.end( );
<a name="l00188"></a>00188 
<a name="l00189"></a>00189     <span class="keywordflow">while</span> ( match_it != match_it_end )
<a name="l00190"></a>00190     {
<a name="l00191"></a>00191       DMatch &amp;point_matcher = ( *match_it );
<a name="l00192"></a>00192 
<a name="l00193"></a>00193       <span class="keywordtype">bool</span> is_found=<span class="keyword">false</span>;
<a name="l00194"></a>00194       vector&lt;TrackOfPoints&gt;::iterator tracks_it = <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ab259863b967c142950a96bc472fd65ef">tracks_</a>.begin( );
<a name="l00195"></a>00195       <span class="keywordflow">while</span> ( tracks_it != <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ab259863b967c142950a96bc472fd65ef">tracks_</a>.end( ) &amp;&amp; !is_found )
<a name="l00196"></a>00196       {
<a name="l00197"></a>00197         <a class="code" href="class_opencv_sf_m_1_1_track_of_points.html" title="This class store the track of keypoints. A track is a connected set of matching keypoints across mult...">TrackOfPoints</a>&amp; track = ( *tracks_it );
<a name="l00198"></a>00198 
<a name="l00199"></a>00199         <span class="keywordflow">if</span>( track.<a class="code" href="class_opencv_sf_m_1_1_track_of_points.html#ac8a9ed8a3334e43833a5e14e79689390">containPoint</a>( img1,point_matcher.trainIdx ))
<a name="l00200"></a>00200         {
<a name="l00201"></a>00201           track.<a class="code" href="class_opencv_sf_m_1_1_track_of_points.html#a83543ac9e156336f5ec070d2963f185c">addMatch</a>( img2,point_matcher.queryIdx );
<a name="l00202"></a>00202           is_found=<span class="keyword">true</span>;
<a name="l00203"></a>00203         }
<a name="l00204"></a>00204         <span class="keywordflow">else</span>
<a name="l00205"></a>00205         {
<a name="l00206"></a>00206           <span class="keywordflow">if</span>( track.<a class="code" href="class_opencv_sf_m_1_1_track_of_points.html#ac8a9ed8a3334e43833a5e14e79689390">containPoint</a>( img2,point_matcher.queryIdx ))
<a name="l00207"></a>00207           {
<a name="l00208"></a>00208             track.<a class="code" href="class_opencv_sf_m_1_1_track_of_points.html#a83543ac9e156336f5ec070d2963f185c">addMatch</a>( img1,point_matcher.trainIdx );
<a name="l00209"></a>00209             is_found=<span class="keyword">true</span>;
<a name="l00210"></a>00210           }
<a name="l00211"></a>00211         }
<a name="l00212"></a>00212         tracks_it++;
<a name="l00213"></a>00213       }
<a name="l00214"></a>00214       <span class="keywordflow">if</span>( !is_found )
<a name="l00215"></a>00215       {
<a name="l00216"></a>00216         <span class="comment">//it&#39;s a new point match, create a new track:</span>
<a name="l00217"></a>00217         <a class="code" href="class_opencv_sf_m_1_1_track_of_points.html" title="This class store the track of keypoints. A track is a connected set of matching keypoints across mult...">TrackOfPoints</a> newTrack;
<a name="l00218"></a>00218         newTrack.<a class="code" href="class_opencv_sf_m_1_1_track_of_points.html#a83543ac9e156336f5ec070d2963f185c">addMatch</a>( img1,point_matcher.trainIdx );
<a name="l00219"></a>00219         newTrack.<a class="code" href="class_opencv_sf_m_1_1_track_of_points.html#a83543ac9e156336f5ec070d2963f185c">addMatch</a>( img2,point_matcher.queryIdx );
<a name="l00220"></a>00220         <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ab259863b967c142950a96bc472fd65ef">tracks_</a>.push_back( newTrack );
<a name="l00221"></a>00221       }
<a name="l00222"></a>00222 
<a name="l00223"></a>00223       match_it++;
<a name="l00224"></a>00224     }
<a name="l00225"></a>00225   }
<a name="l00226"></a>00226 
<a name="l00227"></a><a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ae5a5f33bddb87a0218a26545afdbad8b">00227</a>   <span class="keywordtype">void</span> <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ae5a5f33bddb87a0218a26545afdbad8b">SequenceAnalyzer::addTracks</a>( std::vector&lt; TrackOfPoints &gt; &amp;newTracks )
<a name="l00228"></a>00228   {
<a name="l00229"></a>00229 
<a name="l00230"></a>00230     vector&lt;TrackOfPoints&gt;::iterator match_it = newTracks.begin( ),
<a name="l00231"></a>00231       match_it_end = newTracks.end( );
<a name="l00232"></a>00232 
<a name="l00233"></a>00233     <span class="keywordflow">while</span> ( match_it != match_it_end )
<a name="l00234"></a>00234     {
<a name="l00235"></a>00235       <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ab259863b967c142950a96bc472fd65ef">tracks_</a>.push_back( *match_it );
<a name="l00236"></a>00236 
<a name="l00237"></a>00237       match_it++;
<a name="l00238"></a>00238     }
<a name="l00239"></a>00239   }
<a name="l00240"></a>00240 
<a name="l00241"></a><a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a879aff97ceb6e2b653c48d3fd33b4c98">00241</a>   <span class="keywordtype">void</span> <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a879aff97ceb6e2b653c48d3fd33b4c98">SequenceAnalyzer::showTracks</a>( <span class="keywordtype">int</span> timeBetweenImg )
<a name="l00242"></a>00242   {
<a name="l00243"></a>00243     <span class="keywordflow">if</span>( <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a9e7d1e57d4ff2a80d5ce405e203020b9">points_to_track_</a>.size( ) == 0 )
<a name="l00244"></a>00244       <span class="keywordflow">return</span>;<span class="comment">//nothing to do...</span>
<a name="l00245"></a>00245 
<a name="l00246"></a>00246     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> it=0,it1=0;
<a name="l00247"></a>00247     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> end_iter = <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a9e7d1e57d4ff2a80d5ce405e203020b9">points_to_track_</a>.size( ) - 1 ;
<a name="l00248"></a>00248     <span class="keywordflow">if</span>( <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a07a0b188400adf992b78ada7db54de0e">images_</a>.size( ) - 1 &lt; end_iter )
<a name="l00249"></a>00249       end_iter = <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a07a0b188400adf992b78ada7db54de0e">images_</a>.size( ) - 1;
<a name="l00250"></a>00250     <span class="keywordflow">while</span> ( it &lt; end_iter )
<a name="l00251"></a>00251     {
<a name="l00252"></a>00252       it1=it+1;
<a name="l00253"></a>00253       <span class="keywordflow">while</span> ( it1 &lt; end_iter )
<a name="l00254"></a>00254       {
<a name="l00255"></a>00255         vector&lt;DMatch&gt; matches_to_print;
<a name="l00256"></a>00256         <span class="comment">//add to matches_to_print only points of img it and it+1:</span>
<a name="l00257"></a>00257 
<a name="l00258"></a>00258         vector&lt;TrackOfPoints&gt;::iterator match_it = <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ab259863b967c142950a96bc472fd65ef">tracks_</a>.begin( );
<a name="l00259"></a>00259         vector&lt;TrackOfPoints&gt;::iterator match_it_end = <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ab259863b967c142950a96bc472fd65ef">tracks_</a>.end( );
<a name="l00260"></a>00260 
<a name="l00261"></a>00261         <span class="keywordflow">while</span> ( match_it != match_it_end )
<a name="l00262"></a>00262         {
<a name="l00263"></a>00263           <span class="keywordflow">if</span>( match_it-&gt;containImage( it ) &amp;&amp;
<a name="l00264"></a>00264             match_it-&gt;containImage( it1 ) )
<a name="l00265"></a>00265           {
<a name="l00266"></a>00266             matches_to_print.push_back( match_it-&gt;toDMatch( it,it1 ));
<a name="l00267"></a>00267           }
<a name="l00268"></a>00268           match_it++;
<a name="l00269"></a>00269         }
<a name="l00270"></a>00270 
<a name="l00271"></a>00271         <span class="keywordflow">if</span>( matches_to_print.size()&gt;0 )
<a name="l00272"></a>00272         {
<a name="l00273"></a>00273           Mat firstImg=<a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a07a0b188400adf992b78ada7db54de0e">images_</a>[ it ];
<a name="l00274"></a>00274           Mat outImg;
<a name="l00275"></a>00275 
<a name="l00276"></a>00276           <a class="code" href="class_opencv_sf_m_1_1_points_matcher.html#aa3ddc09d6225a4c167760f17c2999ae3">PointsMatcher::drawMatches</a>( firstImg, <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a9e7d1e57d4ff2a80d5ce405e203020b9">points_to_track_</a>[ it ]-&gt;getKeypoints( ),
<a name="l00277"></a>00277             <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a9e7d1e57d4ff2a80d5ce405e203020b9">points_to_track_</a>[ it1 ]-&gt;getKeypoints( ),
<a name="l00278"></a>00278             matches_to_print, outImg,
<a name="l00279"></a>00279             cv::Scalar::all( -1 ), cv::Scalar::all( -1 ), vector&lt;char&gt;( ),
<a name="l00280"></a>00280             cv::DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS );
<a name="l00281"></a>00281 
<a name="l00282"></a>00282           imshow( <span class="stringliteral">&quot;showTracks&quot;</span>,outImg );
<a name="l00283"></a>00283           cv::waitKey( timeBetweenImg );
<a name="l00284"></a>00284         }
<a name="l00285"></a>00285 
<a name="l00286"></a>00286         it1++;
<a name="l00287"></a>00287       }
<a name="l00288"></a>00288       it++;
<a name="l00289"></a>00289     }
<a name="l00290"></a>00290     cvDestroyWindow( <span class="stringliteral">&quot;showTracks&quot;</span> );
<a name="l00291"></a>00291   }
<a name="l00292"></a>00292 
<a name="l00293"></a><a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a57a64b7f7d27214180c74770e864cde5">00293</a>   <span class="keywordtype">void</span> <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a879aff97ceb6e2b653c48d3fd33b4c98">SequenceAnalyzer::showTracks</a>( <span class="keywordtype">int</span> img_to_show, <span class="keywordtype">int</span> timeBetweenImg )
<a name="l00294"></a>00294   {
<a name="l00295"></a>00295     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> it=0,it1=0;
<a name="l00296"></a>00296     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> end_iter = <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a9e7d1e57d4ff2a80d5ce405e203020b9">points_to_track_</a>.size( ) - 1 ;
<a name="l00297"></a>00297     <span class="keywordflow">if</span>( <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a07a0b188400adf992b78ada7db54de0e">images_</a>.size( ) - 1 &lt; end_iter )
<a name="l00298"></a>00298       end_iter = <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a07a0b188400adf992b78ada7db54de0e">images_</a>.size( ) - 1;
<a name="l00299"></a>00299     vector&lt; vector&lt;DMatch&gt; &gt; matches_to_print;
<a name="l00300"></a>00300     matches_to_print.assign( <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a9e7d1e57d4ff2a80d5ce405e203020b9">points_to_track_</a>.size( ), vector&lt;DMatch&gt;() );
<a name="l00301"></a>00301     <span class="comment">//add to matches_to_print only points of img it and it+1:</span>
<a name="l00302"></a>00302 
<a name="l00303"></a>00303     vector&lt;TrackOfPoints&gt;::iterator match_it = <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ab259863b967c142950a96bc472fd65ef">tracks_</a>.begin( );
<a name="l00304"></a>00304     vector&lt;TrackOfPoints&gt;::iterator match_it_end = <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ab259863b967c142950a96bc472fd65ef">tracks_</a>.end( );
<a name="l00305"></a>00305     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0;
<a name="l00306"></a>00306     <span class="keywordflow">while</span> ( match_it != match_it_end )
<a name="l00307"></a>00307     {
<a name="l00308"></a>00308       <span class="keywordflow">if</span>( match_it-&gt;containImage( img_to_show ) )
<a name="l00309"></a>00309       {
<a name="l00310"></a>00310         <span class="keywordflow">for</span>(i = 0; i&lt;match_it-&gt;images_indexes_.size(); i++)
<a name="l00311"></a>00311         {
<a name="l00312"></a>00312           <span class="keywordflow">if</span>(match_it-&gt;images_indexes_[i] != img_to_show)
<a name="l00313"></a>00313           {
<a name="l00314"></a>00314             matches_to_print[ match_it-&gt;images_indexes_[i] ].
<a name="l00315"></a>00315               push_back( match_it-&gt;toDMatch( img_to_show, match_it-&gt;images_indexes_[i] ));
<a name="l00316"></a>00316           }
<a name="l00317"></a>00317         }
<a name="l00318"></a>00318       }
<a name="l00319"></a>00319       match_it++;
<a name="l00320"></a>00320     }
<a name="l00321"></a>00321 
<a name="l00322"></a>00322     <span class="keywordflow">for</span>(i = 0; i&lt;matches_to_print.size(); i++)
<a name="l00323"></a>00323     {
<a name="l00324"></a>00324       <span class="keywordflow">if</span>( matches_to_print[i].size()&gt;0 )
<a name="l00325"></a>00325       {
<a name="l00326"></a>00326         Mat firstImg=<a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a07a0b188400adf992b78ada7db54de0e">images_</a>[ it ];
<a name="l00327"></a>00327         Mat outImg;
<a name="l00328"></a>00328 
<a name="l00329"></a>00329         <a class="code" href="class_opencv_sf_m_1_1_points_matcher.html#aa3ddc09d6225a4c167760f17c2999ae3">PointsMatcher::drawMatches</a>( firstImg, <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a9e7d1e57d4ff2a80d5ce405e203020b9">points_to_track_</a>[ img_to_show ]-&gt;getKeypoints( ),
<a name="l00330"></a>00330           <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a9e7d1e57d4ff2a80d5ce405e203020b9">points_to_track_</a>[ i ]-&gt;getKeypoints( ),
<a name="l00331"></a>00331           matches_to_print[i], outImg,
<a name="l00332"></a>00332           cv::Scalar::all( -1 ), cv::Scalar::all( -1 ), vector&lt;char&gt;( ),
<a name="l00333"></a>00333           cv::DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS );
<a name="l00334"></a>00334 
<a name="l00335"></a>00335         imshow( <span class="stringliteral">&quot;showTracks&quot;</span>,outImg );
<a name="l00336"></a>00336         cv::waitKey( timeBetweenImg );
<a name="l00337"></a>00337       }
<a name="l00338"></a>00338     }
<a name="l00339"></a>00339     cvDestroyWindow( <span class="stringliteral">&quot;showTracks&quot;</span> );
<a name="l00340"></a>00340   }
<a name="l00341"></a>00341 
<a name="l00342"></a><a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#aa0d8b6f3e4e0a8b1a215e7aa5cd8f00d">00342</a>   <span class="keywordtype">void</span> <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#aa0d8b6f3e4e0a8b1a215e7aa5cd8f00d">SequenceAnalyzer::showTracksBetween</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> img1, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> img2 )
<a name="l00343"></a>00343   {
<a name="l00344"></a>00344     CV_Assert( <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a9e7d1e57d4ff2a80d5ce405e203020b9">points_to_track_</a>.size( ) != 0 );
<a name="l00345"></a>00345     CV_Assert( <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a07a0b188400adf992b78ada7db54de0e">images_</a>.size( ) &gt; img1 &amp;&amp; <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a07a0b188400adf992b78ada7db54de0e">images_</a>.size( ) &gt; img2 );
<a name="l00346"></a>00346 
<a name="l00347"></a>00347     vector&lt;DMatch&gt; matches_to_print,matches_to_print1;
<a name="l00348"></a>00348     <span class="comment">//add to matches_to_print only points of img1 and img2:</span>
<a name="l00349"></a>00349 
<a name="l00350"></a>00350     vector&lt;TrackOfPoints&gt;::iterator match_it = <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ab259863b967c142950a96bc472fd65ef">tracks_</a>.begin( );
<a name="l00351"></a>00351     vector&lt;TrackOfPoints&gt;::iterator match_it_end = <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ab259863b967c142950a96bc472fd65ef">tracks_</a>.end( );
<a name="l00352"></a>00352 
<a name="l00353"></a>00353     <span class="keywordflow">while</span> ( match_it != match_it_end )
<a name="l00354"></a>00354     {
<a name="l00355"></a>00355       <span class="keywordflow">if</span>( match_it-&gt;containImage( img1 ) &amp;&amp;
<a name="l00356"></a>00356         match_it-&gt;containImage( img2 ) )
<a name="l00357"></a>00357       {
<a name="l00358"></a>00358         matches_to_print.push_back( match_it-&gt;toDMatch( img1,img2 ));
<a name="l00359"></a>00359         matches_to_print1.push_back( match_it-&gt;toDMatch( img2,img1 ));
<a name="l00360"></a>00360       }
<a name="l00361"></a>00361       match_it++;
<a name="l00362"></a>00362     }
<a name="l00363"></a>00363 
<a name="l00364"></a>00364     Mat outImg,outImg1;
<a name="l00365"></a>00365     <a class="code" href="class_opencv_sf_m_1_1_points_matcher.html#aa3ddc09d6225a4c167760f17c2999ae3">PointsMatcher::drawMatches</a>( <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a07a0b188400adf992b78ada7db54de0e">images_</a>[ img1 ], <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a9e7d1e57d4ff2a80d5ce405e203020b9">points_to_track_</a>[ img1 ]-&gt;getKeypoints( ),
<a name="l00366"></a>00366       <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a9e7d1e57d4ff2a80d5ce405e203020b9">points_to_track_</a>[ img2 ]-&gt;getKeypoints( ),
<a name="l00367"></a>00367       matches_to_print, outImg,
<a name="l00368"></a>00368       cv::Scalar::all( -1 ), cv::Scalar::all( -1 ), vector&lt;char&gt;( ),
<a name="l00369"></a>00369       cv::DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS );
<a name="l00370"></a>00370     imshow( <span class="stringliteral">&quot;showTracks Img1-Img2&quot;</span>,outImg );
<a name="l00371"></a>00371 
<a name="l00372"></a>00372     <a class="code" href="class_opencv_sf_m_1_1_points_matcher.html#aa3ddc09d6225a4c167760f17c2999ae3">PointsMatcher::drawMatches</a>( <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a07a0b188400adf992b78ada7db54de0e">images_</a>[ img2 ], <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a9e7d1e57d4ff2a80d5ce405e203020b9">points_to_track_</a>[ img2 ]-&gt;getKeypoints( ),
<a name="l00373"></a>00373       <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a9e7d1e57d4ff2a80d5ce405e203020b9">points_to_track_</a>[ img1 ]-&gt;getKeypoints( ),
<a name="l00374"></a>00374       matches_to_print1, outImg1,
<a name="l00375"></a>00375       cv::Scalar::all( -1 ), cv::Scalar::all( -1 ), vector&lt;char&gt;( ),
<a name="l00376"></a>00376       cv::DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS );
<a name="l00377"></a>00377 
<a name="l00378"></a>00378     imshow( <span class="stringliteral">&quot;showTracks Img2-Img1&quot;</span>,outImg1 );
<a name="l00379"></a>00379     cv::waitKey( 0 );
<a name="l00380"></a>00380 
<a name="l00381"></a>00381     cvDestroyWindow( <span class="stringliteral">&quot;showTracks&quot;</span> );
<a name="l00382"></a>00382   }
<a name="l00383"></a>00383 
<a name="l00384"></a><a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a3ffb8dd9711b61523c7f58ffc4ec5bee">00384</a>   <span class="keywordtype">void</span> <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a3ffb8dd9711b61523c7f58ffc4ec5bee">SequenceAnalyzer::read</a>( <span class="keyword">const</span> cv::FileNode&amp; node, <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html" title="This class tries to match points in the entire sequence. It follow ideas proposed by Noah Snavely: Mo...">SequenceAnalyzer</a>&amp; me )
<a name="l00385"></a>00385   {
<a name="l00386"></a>00386     std::string myName=node.name( );
<a name="l00387"></a>00387     <span class="keywordflow">if</span>( myName != <span class="stringliteral">&quot;SequenceAnalyzer&quot;</span> )
<a name="l00388"></a>00388     {
<a name="l00389"></a>00389       std::string error = <span class="stringliteral">&quot;FileNode is not correct!\nExpected \&quot;SequenceAnalyzer\&quot;, got &quot;</span>;
<a name="l00390"></a>00390       error += node.name();
<a name="l00391"></a>00391       CV_Error( CV_StsError, error.c_str() );
<a name="l00392"></a>00392     }
<a name="l00393"></a>00393     <span class="keywordflow">if</span>( node.empty( ) || !node.isMap( ) )
<a name="l00394"></a>00394       CV_Error( CV_StsError, <span class="stringliteral">&quot;SequenceAnalyzer FileNode is not correct!&quot;</span> );
<a name="l00395"></a>00395 
<a name="l00396"></a>00396     <span class="keywordtype">int</span> nb_pictures = ( int ) node[ <span class="stringliteral">&quot;nbPictures&quot;</span> ];
<a name="l00397"></a>00397     <span class="comment">//initialisation of all empty vectors</span>
<a name="l00398"></a>00398     <span class="keywordflow">for</span>( <span class="keywordtype">int</span> i=0; i&lt;nb_pictures; i++ )
<a name="l00399"></a>00399     {
<a name="l00400"></a>00400       Ptr&lt;PointsToTrack&gt; ptt = Ptr&lt;PointsToTrack&gt;( <span class="keyword">new</span> <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html" title="This class can be used to store informations about point and features. This is an abstract class: you...">PointsToTrack</a>( i ));
<a name="l00401"></a>00401       me.<a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a9e7d1e57d4ff2a80d5ce405e203020b9">points_to_track_</a>.push_back( ptt );
<a name="l00402"></a>00402 
<a name="l00403"></a>00403       Ptr&lt;PointsMatcher&gt; p_m = Ptr&lt;PointsMatcher&gt;( <span class="keyword">new</span> <a class="code" href="class_opencv_sf_m_1_1_points_matcher.html" title="A class used for matching descriptors that can be described as vectors in a finite-dimensional space...">PointsMatcher</a>(
<a name="l00404"></a>00404         *me.<a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a3c3ffb9390f94294e010d38e64bffc25">match_algorithm_</a> ) );
<a name="l00405"></a>00405       p_m-&gt;add( ptt );
<a name="l00406"></a>00406 
<a name="l00407"></a>00407       me.<a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#adb773da58cbaca8ff8d681b20c4007ab">matches_</a>.push_back( p_m );
<a name="l00408"></a>00408     }
<a name="l00409"></a>00409 
<a name="l00410"></a>00410     cv::FileNode node_TrackPoints = node[ <span class="stringliteral">&quot;TrackPoints&quot;</span> ];
<a name="l00411"></a>00411 
<a name="l00412"></a>00412     <span class="comment">//tracks are stored in the following form:</span>
<a name="l00413"></a>00413     <span class="comment">//list of track where a track is stored like this:</span>
<a name="l00414"></a>00414     <span class="comment">// nbPoints idImage1 point1  idImage2 point2 ...</span>
<a name="l00415"></a>00415     <span class="keywordflow">if</span>( node_TrackPoints.empty( ) || !node_TrackPoints.isSeq( ) )
<a name="l00416"></a>00416       CV_Error( CV_StsError, <span class="stringliteral">&quot;SequenceAnalyzer FileNode is not correct!&quot;</span> );
<a name="l00417"></a>00417     cv::FileNodeIterator it = node_TrackPoints.begin( ),
<a name="l00418"></a>00418       it_end = node_TrackPoints.end( );
<a name="l00419"></a>00419     <span class="keywordflow">while</span>( it != it_end )
<a name="l00420"></a>00420     {
<a name="l00421"></a>00421       cv::FileNode it_track = ( *it )[ 0 ];
<a name="l00422"></a>00422       <span class="keywordtype">int</span> nbPoints,track_consistance;
<a name="l00423"></a>00423       it_track[ <span class="stringliteral">&quot;nbPoints&quot;</span> ] &gt;&gt; nbPoints;
<a name="l00424"></a>00424       it_track[ <span class="stringliteral">&quot;track_consistance&quot;</span> ] &gt;&gt; track_consistance;
<a name="l00425"></a>00425       <span class="keywordtype">bool</span> has_3d_point = <span class="keyword">false</span>;
<a name="l00426"></a>00426       it_track[ <span class="stringliteral">&quot;has_3d_position&quot;</span> ] &gt;&gt; has_3d_point;
<a name="l00427"></a>00427       <a class="code" href="class_opencv_sf_m_1_1_track_of_points.html" title="This class store the track of keypoints. A track is a connected set of matching keypoints across mult...">TrackOfPoints</a> track;
<a name="l00428"></a>00428       <span class="keywordflow">if</span>( has_3d_point )
<a name="l00429"></a>00429       {
<a name="l00430"></a>00430         cv::Vec3d point;
<a name="l00431"></a>00431         point[ 0 ] = it_track[ <span class="stringliteral">&quot;point3D_triangulated&quot;</span> ][ 0 ];
<a name="l00432"></a>00432         point[ 1 ] = it_track[ <span class="stringliteral">&quot;point3D_triangulated&quot;</span> ][ 1 ];
<a name="l00433"></a>00433         point[ 2 ] = it_track[ <span class="stringliteral">&quot;point3D_triangulated&quot;</span> ][ 2 ];
<a name="l00434"></a>00434         track.<a class="code" href="class_opencv_sf_m_1_1_track_of_points.html#ad47f8be9467b36497a7484aea438cbcc" title="The corresponding 3D coordinates. If not available, Ptr is empty.">point3D</a> = Ptr&lt;cv::Vec3d&gt;( <span class="keyword">new</span> cv::Vec3d( point ) );
<a name="l00435"></a>00435       }
<a name="l00436"></a>00436       <span class="keywordtype">int</span> color;
<a name="l00437"></a>00437       it_track[ <span class="stringliteral">&quot;color&quot;</span> ] &gt;&gt; color;
<a name="l00438"></a>00438       track.<a class="code" href="class_opencv_sf_m_1_1_track_of_points.html#a8dd77a29977f8231ebcf17bcabc8abc8">setColor</a>( *((<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>*)&amp;color) );
<a name="l00439"></a>00439       cv::FileNodeIterator itPoints = it_track[ <span class="stringliteral">&quot;list_of_points&quot;</span> ].begin( ),
<a name="l00440"></a>00440         itPoints_end = it_track[ <span class="stringliteral">&quot;list_of_points&quot;</span> ].end( );
<a name="l00441"></a>00441       <span class="keywordflow">while</span>( itPoints != itPoints_end )
<a name="l00442"></a>00442       {
<a name="l00443"></a>00443         <span class="keywordtype">int</span> idImage;
<a name="l00444"></a>00444         cv::KeyPoint kpt;
<a name="l00445"></a>00445         idImage = ( *itPoints )[ 0 ];
<a name="l00446"></a>00446         itPoints++;
<a name="l00447"></a>00447         kpt.pt.x = ( *itPoints )[ 0 ];
<a name="l00448"></a>00448         kpt.pt.y = ( *itPoints )[ 1 ];
<a name="l00449"></a>00449         kpt.size = ( *itPoints )[ 2 ];
<a name="l00450"></a>00450         kpt.angle = ( *itPoints )[ 3 ];
<a name="l00451"></a>00451         kpt.response = ( *itPoints )[ 4 ];
<a name="l00452"></a>00452         kpt.octave = ( *itPoints )[ 5 ];
<a name="l00453"></a>00453         kpt.class_id = ( *itPoints )[ 6 ];
<a name="l00454"></a>00454 
<a name="l00455"></a>00455         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> point_index = me.<a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a9e7d1e57d4ff2a80d5ce405e203020b9">points_to_track_</a>[ idImage ]-&gt;
<a name="l00456"></a>00456           addKeypoint( kpt );
<a name="l00457"></a>00457         track.<a class="code" href="class_opencv_sf_m_1_1_track_of_points.html#a83543ac9e156336f5ec070d2963f185c">addMatch</a>( idImage,point_index );
<a name="l00458"></a>00458 
<a name="l00459"></a>00459         itPoints++;
<a name="l00460"></a>00460       }
<a name="l00461"></a>00461       track.<a class="code" href="class_opencv_sf_m_1_1_track_of_points.html#ada7b5f6522454fe0a57438396e3ef24c">track_consistance</a> = track_consistance;
<a name="l00462"></a>00462       me.<a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ab259863b967c142950a96bc472fd65ef">tracks_</a>.push_back( track );
<a name="l00463"></a>00463       it++;
<a name="l00464"></a>00464     }
<a name="l00465"></a>00465   }
<a name="l00466"></a>00466 
<a name="l00467"></a><a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a945b5f532e21f8cbdd067ddb070cccb1">00467</a>   <span class="keywordtype">void</span> <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a945b5f532e21f8cbdd067ddb070cccb1">SequenceAnalyzer::write</a>( cv::FileStorage&amp; fs, <span class="keyword">const</span> <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html" title="This class tries to match points in the entire sequence. It follow ideas proposed by Noah Snavely: Mo...">SequenceAnalyzer</a>&amp; me )
<a name="l00468"></a>00468   {
<a name="l00469"></a>00469     vector&lt;TrackOfPoints&gt;::size_type key_size = me.<a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ab259863b967c142950a96bc472fd65ef">tracks_</a>.size( );
<a name="l00470"></a>00470     <span class="keywordtype">int</span> idImage=-1, idPoint=-1;
<a name="l00471"></a>00471 
<a name="l00472"></a>00472     fs &lt;&lt; <span class="stringliteral">&quot;SequenceAnalyzer&quot;</span> &lt;&lt; <span class="stringliteral">&quot;{&quot;</span>;
<a name="l00473"></a>00473     fs &lt;&lt; <span class="stringliteral">&quot;nbPictures&quot;</span> &lt;&lt; ( int )me.<a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a9e7d1e57d4ff2a80d5ce405e203020b9">points_to_track_</a>.size( );
<a name="l00474"></a>00474     fs &lt;&lt; <span class="stringliteral">&quot;nbPoints&quot;</span> &lt;&lt; ( int )key_size;
<a name="l00475"></a>00475     fs &lt;&lt; <span class="stringliteral">&quot;TrackPoints&quot;</span> &lt;&lt; <span class="stringliteral">&quot;[&quot;</span>;
<a name="l00476"></a>00476     <span class="keywordflow">for</span> ( vector&lt;TrackOfPoints&gt;::size_type i=0; i &lt; key_size; i++ )
<a name="l00477"></a>00477     {
<a name="l00478"></a>00478       <span class="keyword">const</span> <a class="code" href="class_opencv_sf_m_1_1_track_of_points.html" title="This class store the track of keypoints. A track is a connected set of matching keypoints across mult...">TrackOfPoints</a> &amp;track = me.<a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ab259863b967c142950a96bc472fd65ef">tracks_</a>[ i ];
<a name="l00479"></a>00479       <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nbPoints = track.<a class="code" href="class_opencv_sf_m_1_1_track_of_points.html#a3e18eabd0bbdc80e5a183eaf3d6a8d69">getNbTrack</a>( );
<a name="l00480"></a>00480       <span class="keywordflow">if</span>( nbPoints &gt; 0 )
<a name="l00481"></a>00481       {
<a name="l00482"></a>00482         fs &lt;&lt; <span class="stringliteral">&quot;{&quot;</span> &lt;&lt; <span class="stringliteral">&quot;nbPoints&quot;</span> &lt;&lt; ( int )nbPoints;
<a name="l00483"></a>00483         fs &lt;&lt; <span class="stringliteral">&quot;track_consistance&quot;</span> &lt;&lt; track.<a class="code" href="class_opencv_sf_m_1_1_track_of_points.html#ada7b5f6522454fe0a57438396e3ef24c">track_consistance</a>;
<a name="l00484"></a>00484         fs &lt;&lt; <span class="stringliteral">&quot;has_3d_position&quot;</span> &lt;&lt; ( !track.<a class="code" href="class_opencv_sf_m_1_1_track_of_points.html#ad47f8be9467b36497a7484aea438cbcc" title="The corresponding 3D coordinates. If not available, Ptr is empty.">point3D</a>.empty( ) );
<a name="l00485"></a>00485         <span class="keywordflow">if</span>( !track.<a class="code" href="class_opencv_sf_m_1_1_track_of_points.html#ad47f8be9467b36497a7484aea438cbcc" title="The corresponding 3D coordinates. If not available, Ptr is empty.">point3D</a>.empty( ) )
<a name="l00486"></a>00486           fs &lt;&lt; <span class="stringliteral">&quot;point3D_triangulated&quot;</span> &lt;&lt; *(track.<a class="code" href="class_opencv_sf_m_1_1_track_of_points.html#ad47f8be9467b36497a7484aea438cbcc" title="The corresponding 3D coordinates. If not available, Ptr is empty.">point3D</a>);
<a name="l00487"></a>00487 
<a name="l00488"></a>00488         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> real_color = track.<a class="code" href="class_opencv_sf_m_1_1_track_of_points.html#aae4506ca2306c22e44d4577467b1b545">getColor</a>();
<a name="l00489"></a>00489         <span class="keywordtype">int</span> color = *((<span class="keywordtype">int</span>*)&amp;real_color);
<a name="l00490"></a>00490         fs &lt;&lt; <span class="stringliteral">&quot;color&quot;</span> &lt;&lt; color;
<a name="l00491"></a>00491 
<a name="l00492"></a>00492         fs &lt;&lt; <span class="stringliteral">&quot;list_of_points&quot;</span> &lt;&lt; <span class="stringliteral">&quot;[:&quot;</span>;
<a name="l00493"></a>00493         nbPoints = track.<a class="code" href="class_opencv_sf_m_1_1_track_of_points.html#a3a03a4468cd94b38de2b8a9787379801" title="List of image indexes of unordered points.">images_indexes_</a>.size();
<a name="l00494"></a>00494         <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> j = 0; j &lt; nbPoints ; j++ )
<a name="l00495"></a>00495         {
<a name="l00496"></a>00496           <span class="keywordflow">if</span>( track.<a class="code" href="class_opencv_sf_m_1_1_track_of_points.html#af55a2dcf8abb42bdb1827e38eee9866b">good_values</a>[j] )
<a name="l00497"></a>00497           {
<a name="l00498"></a>00498             idImage = track.<a class="code" href="class_opencv_sf_m_1_1_track_of_points.html#a3a03a4468cd94b38de2b8a9787379801" title="List of image indexes of unordered points.">images_indexes_</a>[ j ];
<a name="l00499"></a>00499             idPoint = track.<a class="code" href="class_opencv_sf_m_1_1_track_of_points.html#a245986f9cdf722e5aec386585677a188" title="List of point indexes of unordered points.">point_indexes_</a>[ j ];
<a name="l00500"></a>00500             <span class="keywordflow">if</span>( idImage&gt;=0 &amp;&amp; idPoint&gt;=0 )
<a name="l00501"></a>00501             {
<a name="l00502"></a>00502               fs &lt;&lt; idImage;
<a name="l00503"></a>00503               fs  &lt;&lt; <span class="stringliteral">&quot;[:&quot;</span>;
<a name="l00504"></a>00504 
<a name="l00505"></a>00505               <span class="keyword">const</span> cv::KeyPoint kpt = me.<a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a9e7d1e57d4ff2a80d5ce405e203020b9">points_to_track_</a>[ idImage ]-&gt;
<a name="l00506"></a>00506                 getKeypoints( )[ idPoint ];
<a name="l00507"></a>00507               <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a945b5f532e21f8cbdd067ddb070cccb1">cv::write</a>( fs, kpt.pt.x );
<a name="l00508"></a>00508               <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a945b5f532e21f8cbdd067ddb070cccb1">cv::write</a>( fs, kpt.pt.y );
<a name="l00509"></a>00509               <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a945b5f532e21f8cbdd067ddb070cccb1">cv::write</a>( fs, kpt.size );
<a name="l00510"></a>00510               <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a945b5f532e21f8cbdd067ddb070cccb1">cv::write</a>( fs, kpt.angle );
<a name="l00511"></a>00511               <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a945b5f532e21f8cbdd067ddb070cccb1">cv::write</a>( fs, kpt.response );
<a name="l00512"></a>00512               <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a945b5f532e21f8cbdd067ddb070cccb1">cv::write</a>( fs, kpt.octave );
<a name="l00513"></a>00513               <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a945b5f532e21f8cbdd067ddb070cccb1">cv::write</a>( fs, kpt.class_id );
<a name="l00514"></a>00514               fs &lt;&lt; <span class="stringliteral">&quot;]&quot;</span> ;
<a name="l00515"></a>00515             }
<a name="l00516"></a>00516           }
<a name="l00517"></a>00517         }
<a name="l00518"></a>00518         fs &lt;&lt; <span class="stringliteral">&quot;]&quot;</span> &lt;&lt; <span class="stringliteral">&quot;}&quot;</span> ;
<a name="l00519"></a>00519       }
<a name="l00520"></a>00520     }
<a name="l00521"></a>00521     fs &lt;&lt; <span class="stringliteral">&quot;]&quot;</span> &lt;&lt; <span class="stringliteral">&quot;}&quot;</span>;
<a name="l00522"></a>00522   }
<a name="l00523"></a>00523 
<a name="l00524"></a><a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ae13ebc853e768f64420ccbe8974e2f63">00524</a>   <span class="keywordtype">void</span> <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ae13ebc853e768f64420ccbe8974e2f63">SequenceAnalyzer::constructImagesGraph</a>( )
<a name="l00525"></a>00525   {
<a name="l00526"></a>00526     <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a2f06b4e79d38b6fa0315751eeb545c81">images_graph_</a>.<a class="code" href="class_opencv_sf_m_1_1_images_graph_connection.html#a2419d1c31eb4e85caebcadd66a8134c7">initStructure</a>( <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a9e7d1e57d4ff2a80d5ce405e203020b9">points_to_track_</a>.size( ) );
<a name="l00527"></a>00527 
<a name="l00528"></a>00528     <span class="comment">//for each points:</span>
<a name="l00529"></a>00529     vector&lt;TrackOfPoints&gt;::size_type key_size = <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ab259863b967c142950a96bc472fd65ef">tracks_</a>.size( );
<a name="l00530"></a>00530     vector&lt;TrackOfPoints&gt;::size_type i;
<a name="l00531"></a>00531 
<a name="l00532"></a>00532     <span class="keywordflow">for</span> ( i=0; i &lt; key_size; i++ )
<a name="l00533"></a>00533     {
<a name="l00534"></a>00534       <a class="code" href="class_opencv_sf_m_1_1_track_of_points.html" title="This class store the track of keypoints. A track is a connected set of matching keypoints across mult...">TrackOfPoints</a> &amp;track = <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ab259863b967c142950a96bc472fd65ef">tracks_</a>[ i ];
<a name="l00535"></a>00535       <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nviews = track.<a class="code" href="class_opencv_sf_m_1_1_track_of_points.html#a3a03a4468cd94b38de2b8a9787379801" title="List of image indexes of unordered points.">images_indexes_</a>.size( );
<a name="l00536"></a>00536 
<a name="l00537"></a>00537       <span class="keywordflow">for</span>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> cpt=0;cpt&lt;nviews;cpt++ )
<a name="l00538"></a>00538       {
<a name="l00539"></a>00539         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> imgSrc = track.<a class="code" href="class_opencv_sf_m_1_1_track_of_points.html#a3a03a4468cd94b38de2b8a9787379801" title="List of image indexes of unordered points.">images_indexes_</a>[ cpt ];
<a name="l00540"></a>00540         <span class="keywordflow">for</span>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> cpt1=imgSrc+1;cpt1&lt;nviews;cpt1++ )
<a name="l00541"></a>00541         {
<a name="l00542"></a>00542           <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a2f06b4e79d38b6fa0315751eeb545c81">images_graph_</a>.<a class="code" href="class_opencv_sf_m_1_1_images_graph_connection.html#a966c6d3f7fb148dfa05be5b77a343dcd">addLink</a>( imgSrc, track.<a class="code" href="class_opencv_sf_m_1_1_track_of_points.html#a3a03a4468cd94b38de2b8a9787379801" title="List of image indexes of unordered points.">images_indexes_</a>[ cpt1 ] );
<a name="l00543"></a>00543         }
<a name="l00544"></a>00544       }
<a name="l00545"></a>00545     }
<a name="l00546"></a>00546   }
<a name="l00547"></a>00547 
<a name="l00548"></a><a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#aa78d5d8f14b5f60abb9924a1f8e5a829">00548</a>   std::vector&lt; cv::Vec3d &gt; <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#aa78d5d8f14b5f60abb9924a1f8e5a829">SequenceAnalyzer::get3DStructure</a>( )
<a name="l00549"></a>00549   {
<a name="l00550"></a>00550     vector&lt;cv::Vec3d&gt; out_vector;
<a name="l00551"></a>00551     vector&lt;TrackOfPoints&gt;::iterator itTrack=<a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ab259863b967c142950a96bc472fd65ef">tracks_</a>.begin( );
<a name="l00552"></a>00552     <span class="keywordflow">while</span> ( itTrack != <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ab259863b967c142950a96bc472fd65ef">tracks_</a>.end( ) )
<a name="l00553"></a>00553     {
<a name="l00554"></a>00554       <span class="keywordflow">if</span>( !itTrack-&gt;point3D.empty( ) )
<a name="l00555"></a>00555         out_vector.push_back( ( cv::Vec3d )( *itTrack ) );
<a name="l00556"></a>00556       itTrack++;
<a name="l00557"></a>00557     }
<a name="l00558"></a>00558     <span class="keywordflow">return</span> out_vector;
<a name="l00559"></a>00559   }
<a name="l00560"></a>00560 
<a name="l00561"></a><a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#afe9350556bd2bbb2c46204b182f9d119">00561</a>   std::vector&lt; unsigned int &gt; <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#afe9350556bd2bbb2c46204b182f9d119">SequenceAnalyzer::getColors</a>( )
<a name="l00562"></a>00562   {
<a name="l00563"></a>00563     vector&lt;unsigned int&gt; out_vector;
<a name="l00564"></a>00564     vector&lt;TrackOfPoints&gt;::iterator itTrack=<a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ab259863b967c142950a96bc472fd65ef">tracks_</a>.begin( );
<a name="l00565"></a>00565     <span class="keywordflow">while</span> ( itTrack != <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#ab259863b967c142950a96bc472fd65ef">tracks_</a>.end( ) )
<a name="l00566"></a>00566     {
<a name="l00567"></a>00567       <span class="keywordflow">if</span>( !itTrack-&gt;point3D.empty( ) )
<a name="l00568"></a>00568         out_vector.push_back( itTrack-&gt;getColor() );
<a name="l00569"></a>00569       itTrack++;
<a name="l00570"></a>00570     }
<a name="l00571"></a>00571     <span class="keywordflow">return</span> out_vector;
<a name="l00572"></a>00572   }
<a name="l00573"></a>00573 
<a name="l00574"></a><a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#aab618b81991736633095ce24c07013a3">00574</a>   <span class="keywordtype">void</span> <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#aab618b81991736633095ce24c07013a3">SequenceAnalyzer::showPointsOnImage</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i,
<a name="l00575"></a>00575     <span class="keyword">const</span> std::vector&lt;cv::Vec2d&gt;&amp; pixelProjection)
<a name="l00576"></a>00576   {
<a name="l00577"></a>00577     CV_Assert( i &lt; <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a07a0b188400adf992b78ada7db54de0e">images_</a>.size() );
<a name="l00578"></a>00578     <span class="comment">//convert Vec2D into Keypoints:</span>
<a name="l00579"></a>00579     std::vector&lt;KeyPoint&gt; keypoints;
<a name="l00580"></a>00580     <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> cpt = 0; cpt&lt;pixelProjection.size(); ++cpt)
<a name="l00581"></a>00581     {
<a name="l00582"></a>00582       keypoints.push_back( cv::KeyPoint( (<span class="keywordtype">float</span>)pixelProjection[ cpt ][0],
<a name="l00583"></a>00583         (<span class="keywordtype">float</span>)pixelProjection[ cpt ][1], 1.0 ) );
<a name="l00584"></a>00584     }
<a name="l00585"></a>00585     cv::Mat outImg;
<a name="l00586"></a>00586     cv::drawKeypoints( <a class="code" href="class_opencv_sf_m_1_1_sequence_analyzer.html#a07a0b188400adf992b78ada7db54de0e">images_</a>[i], keypoints, outImg );
<a name="l00587"></a>00587     cv::imshow( <span class="stringliteral">&quot;Keypoints&quot;</span>, outImg );
<a name="l00588"></a>00588     cv::waitKey( 0 );
<a name="l00589"></a>00589     cv::destroyWindow( <span class="stringliteral">&quot;Keypoints&quot;</span> );
<a name="l00590"></a>00590   }
<a name="l00591"></a>00591 }
</pre></div></div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generated on Sun Aug 21 2011 16:45:52 for GSoC2011SfM by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.5.1
</small></address>

</body>
</html>
